<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加用户</title>
    <!-- easyui框架CSS -->
    <link href="${prc}/css/easyui.css" rel="stylesheet">
    <link href="${prc}/css/icon.css" rel="stylesheet">
        <!-- easyui框架JS -->
    <script src="${prc}/js/jquery.min.js"></script>
    <script src="${prc}/js/jquery.easyui.min.js"></script>
    <script src="${prc}/js/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
	$(function(){
		
		if("${tip}"){
			var msg = "${tip}";
			$.messager.alert('温馨提示',msg,'warning');
		}
		/** 给提交按钮绑定点击事件 */
		$("#btn_submit").click(function(){
			// 对表单中所有字段做校验
			var userId = $("#userId");
			var passWord = $("#passWord");
			var userSex = $("#userSex");
			var userLanguage = $("#userLanguage");
			var userRace = $("#userRace");
			var userMailBox = $("#userMailBox");
			var userPhoneNumBer = $("#userPhoneNumBer");
			var repwd = $("#repwd");
			var msg = "";
			if ($.trim(userId.val()) == ""){
				msg += "用户登录名不能为空!";
				userId.focus();
			}else if (!/^\w{5,20}$/.test(userId.val())){
				msg += "用户登录名长度必须在5-20之间!";
				userId.focus();
			}else if ($.trim(passWord.val()) == ""){
				msg += "密码不能为空!";
				passWord.focus();
			}else if (!/^\w{6,20}$/.test(passWord.val())){
				msg += "密码长度必须为6-20之间!";
				passWord.focus();
			}else if (repwd.val() != passWord.val()){
				msg += "两次输入的密码不一致!";
				repwd.focus();
			}else if($.trim(userMailBox.val()) == ""){
				msg += "邮箱不能为空!";
				userMailBox.focus();
			}else if(!/^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/.test(userMailBox.val())){
				msg += "邮箱格式错误!"
				userMailBox.focus();
			}else if($.trim(userPhoneNumBer.val()) == ""){
				msg += "电话不能为空!";
				userPhoneNumBer.focus();
			}else if(!/^1[34578]\d{9}$/.test(userPhoneNumBer.val())){
				msg += "手机号码格式不正确!";
				userPhoneNumBer.focus();
			}
			
			if(msg){
				$.messager.alert('温馨提示',msg,'warning');
			}else{
				//直接提交表单
				$("#addUserForm").submit();
				
			}
			
		});
	});
	
    </script>
</head>
<body>

<s:form action="user/savaUser.action" method="post" id="addUserForm" theme="simple">
	<table cellpadding="5">
		<tr>
	    	<td>用户名:</td>
	    	<td><input class="easyui-textbox" style="width:100%;height:32px" type="text" id="userId" name="user.userId" value="${user.userId}" data-options="required:true"></input></td>
	    </tr>
	    <tr>
	    	<td>密码:</td>
	    	<td><input class="easyui-textbox" style="width:100%;height:32px" type="password" id="passWord" name="user.passWord" value="${user.userId}" data-options="required:true"></input></td>
	    </tr>
	    <tr>
	    	<td>重输密码:</td>
	    	<td><input class="easyui-textbox" style="width:100%;height:32px" type="password" id="repwd" name="repwd" value="${user.userId}" data-options="required:true"></input></td>
	    </tr>
	    <tr>
	    	<td>性别:</td>
	    	<td>
	    		<select class="easyui-combobox" id="userSex" name="user.userSex">
	    		<option value="男" selected="selected">&nbsp;男&nbsp;</option>
	    		<option value="女">&nbsp;女&nbsp;</option>
	    		</select>
	    	</td>
	    </tr>
	    <tr>
	    	<td>语言:</td>
	    	<td>
	    		<select class="easyui-combobox" id="userLanguage" name="user.userLanguage">
	    		<option value="汉语" selected="selected">&nbsp;汉语&nbsp;</option>
	    		<option value="英文">&nbsp;英语&nbsp;</option>
	    		<option value="其它">&nbsp;其它&nbsp;</option>
	    		</select>
	    	</td>
	    </tr>
	    <tr>
	    	<td>种族:</td>
	    	<td>
	    		<select class="easyui-combobox" id="userRace" name="user.userRace">
	    		<option value="汉族" selected="selected">&nbsp;汉族&nbsp;</option>
	    		<option value="回族">&nbsp;回族&nbsp;</option>
	    		<option value="满族">&nbsp;满族&nbsp;</option>
	    		<option value="畲族">&nbsp;畲族&nbsp;</option>
	    		<option value="其它">&nbsp;其它&nbsp;</option>
	    		</select>
	    	</td>
	    </tr>
	    <tr>
	    	<td>邮箱:</td>
	    	<td><input class="easyui-textbox" style="width:100%;height:32px" type="text" id="userMailBox" name="user.userMailBox" data-options="required:true,validType:'email'"></input></td>
	   </tr>
	   <tr>
	    	<td>电话:</td>
	    	<td><input class="easyui-textbox" style="width:100%;height:32px" type="text" id="userPhoneNumBer" name="user.userPhoneNumBer" data-options="required:true"></input></td>
	    </tr>
	    <tr>
		   <td>
		   	<input class="easyui-linkbutton" style="width:100%;height:32px" value="提交" type="button" id="btn_submit" /> 
		   </td>
	    </tr>
	</table>
</s:form>
</body>
</html>